<template>
  <!--课题(选题)信息（审核/详情）-->
  <div class="edu-page-warp topic-info">
    <DesignCard :title="$t('graduationDesign.basicInfo')" :isShow="actionType !== 'ADD' && actionType !== 'EDIT'">
      <!--基本信息-->
      <el-form :model="basicInfoForm" ref="basicInfoForm" :rules="basicInfoRules" label-position="right" label-suffix="：" :label-width="labelWidth" :disabled="VIEW.includes(actionType)">
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('graduationDesign.subjectName')" prop="projectName">
              <el-input v-model="basicInfoForm.projectName" maxlength="100" class="topic-input-select" :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('graduationDesign.subtitle')">
              <el-input v-model="basicInfoForm.subtitleName" maxlength="100" class="topic-input-select" :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item :label="$t('graduationDesign.researchDirection')" prop="researchDirection">
              <el-input v-model="basicInfoForm.researchDirection" class="topic-input-select" type="textarea" :rows="4" maxlength="200" show-word-limit :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item :label="$t('graduationDesign.subjectIntroduction')" prop="introductionProject">
              <el-input v-model="basicInfoForm.introductionProject" class="topic-input-select" type="textarea" :rows="4" maxlength="200" show-word-limit :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <!--申请原因 可见-->
        <el-row v-if="actionType === 'VIEW_TOPIC_RESULT' || actionType === 'VIEW_TOPIC_REASON'">
          <el-col>
            <el-form-item :label="$t('graduationDesign.applicationReason')" prop="applyDesc">
              <el-input v-model="basicInfoForm.applyDesc" class="topic-input-select" type="textarea" :rows="4" maxlength="200" show-word-limit :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item :label="STUDENT_BASIC_INFO.includes(actionType) ? $t('graduationDesign.subjectMajor') : $t('graduationDesign.subjectAttributes')" class="topic-form-title"></el-form-item>
        <el-row>
          <el-col :span="12" v-if="TUTOR_BASIC_INFO.includes(actionType)">
            <el-form-item :label="$t('graduationDesign.graduationYear')" prop="grade">
              <el-date-picker class="topic-input-select" v-model="basicInfoForm.grade" @change="handleGradeChange" value-format="yyyy" type="year" :placeholder="$t('graduationDesign.defaultCurrentYear')">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('graduationDesign.college')" prop="college">
              <el-select v-model="basicInfoForm.college" @change="handleCollegeChange" class="topic-input-select" clearable filterable :placeholder="$t('graduationDesign.defaultCollege')">
                <el-option v-for="item in source.collegeOptions" :key="item.collegeId" :label="item.collegeIdI18n" :value="item.collegeId"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('graduationDesign.major')" prop="subjectId">
              <el-select v-model="basicInfoForm.subjectId" @change="handleSubjectChange" class="topic-input-select" clearable filterable :placeholder="$t('graduationDesign.pleaseChoose')">
                <el-option v-for="item in source.subjectOptions" :key="item.subjectId" :label="item.subjectName" :value="item.subjectId"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('graduationDesign.direction')" prop="direction">
              <el-select v-model="basicInfoForm.direction" class="topic-input-select" clearable filterable :placeholder="$t('graduationDesign.pleaseChoose')">
                <el-option v-for="item in source.directionOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="TUTOR_BASIC_INFO.includes(actionType)">
            <el-form-item :label="$t('graduationDesign.hasOutsideTutor')" prop="isOutside">
              <el-select v-model="basicInfoForm.isOutside" class="topic-input-select" @change="handleOutsideChange" clearable filterable :placeholder="$t('graduationDesign.defaultNo')">
                <el-option v-for="item in source.isTutorOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="TUTOR_BASIC_INFO.includes(actionType) && this.basicInfoForm.isOutside">
            <el-form-item :label="$t('graduationDesign.outsideTutor')" prop="outsideTeacherNum">
              <el-select v-model="basicInfoForm.outsideTeacherNum" class="topic-input-select" clearable filterable :placeholder="$t('graduationDesign.pleaseChoose')">
                <el-option v-for="item in source.outsideTutorOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-form-item :label="$t('graduationDesign.subjectSituation')" class="topic-form-title"></el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item :label="$t('graduationDesign.subjectType')" prop="projectType">
              <el-select v-model="basicInfoForm.projectType" class="topic-input-select" clearable filterable :placeholder="$t('graduationDesign.pleaseChoose')">
                <el-option v-for="item in source.subjectTypeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('graduationDesign.subjectSource')" prop="projectSourceId">
              <el-select v-model="basicInfoForm.projectSourceId" class="topic-input-select" clearable filterable :placeholder="$t('graduationDesign.pleaseChoose')">
                <el-option v-for="item in source.subjectSourceOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('graduationDesign.subjectNature')" prop="projectNatureId">
              <el-select v-model="basicInfoForm.projectNatureId" class="topic-input-select" clearable filterable :placeholder="$t('graduationDesign.pleaseChoose')">
                <el-option v-for="item in source.subjectNatureOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('graduationDesign.socialPractice')" prop="practiceSocialId">
              <el-select v-model="basicInfoForm.practiceSocialId" class="topic-input-select" clearable filterable :placeholder="$t('graduationDesign.pleaseChoose')">
                <el-option v-for="item in source.socialPracticeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item :label="$t('graduationDesign.graduationDesignLocation')" prop="designPlace">
              <el-input v-model="basicInfoForm.designPlace" maxlength="60" class="topic-input-select" :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="STUDENT_BASIC_INFO.includes(actionType)">
            <el-form-item :label="$t('graduationDesign.instructor')">
              <el-select v-model="basicInfoForm.teacherNum" class="topic-input-select" clearable filterable :placeholder="$t('graduationDesign.pleaseChoose')">
                <el-option v-for="item in source.innerTutorOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <!--选题查看-->
        <div v-if="TOPIC_VIEW.includes(actionType)">
          <el-row>
            <el-col :span="12">
              <el-form-item :label="$t('graduationDesign.subjectApplicant')">
                <el-input v-model="basicInfoForm.applicantName" class="topic-input-select" :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item :label="$t('graduationDesign.tutor')">
                <el-input v-model="basicInfoForm.teacherName" class="topic-input-select" :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('graduationDesign.college')">
                <el-input v-model="basicInfoForm.collegeI18n" class="topic-input-select" :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item :label="$t('graduationDesign.student')">
                <el-input v-model="basicInfoForm.studentName" class="topic-input-select" :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('graduationDesign.college')">
                <el-input v-model="basicInfoForm.stuCollegeI18n" class="topic-input-select" :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item :label="$t('graduationDesign.major')">
                <el-input v-model="basicInfoForm.stuSubjectIdI18n" class="topic-input-select" :placeholder="$t('graduationDesign.pleaseEnter')"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>
      <div v-if="actionType === 'ADD' || actionType === 'EDIT'">
        <hr>
        <div class="edu-opertion-bar">
          <div class="float-right">
            <el-button @click="onCancel">{{$t('graduationDesign.cancel')}}</el-button>
            <el-button type="primary" @click="onSave">{{$t('graduationDesign.save')}}</el-button>
            <el-button type="primary" @click="onSubmit">{{$t('graduationDesign.submit')}}</el-button>
          </div>
        </div>
      </div>
    </DesignCard>

    <!--审核 仅审核状态时("REVIEW_STU"/"REVIEW_TUTOR")可见-->
    <el-card shadow="never" v-if="REVIEW.includes(actionType)">
      <el-row :gutter="20" type="flex" align="center" justify="space-between" style="margin:16px 0">
        <el-col>
          <span class="topic-title">{{$t('graduationDesign.review')}}</span>
        </el-col>
      </el-row>
      <el-form :model="reviewForm" ref="reviewForm" :rules="reviewRules" label-position="right" label-suffix="：" :label-width="labelWidth">
        <el-form-item :label="$t('graduationDesign.reviewDescription')" prop="remark">
          <el-input v-model="reviewForm.remark" class="topic-input-select" type="textarea" :rows="3" maxlength="1000" show-word-limit :placeholder="$t('graduationDesign.requiredWhenRejected')"></el-input>
        </el-form-item>
      </el-form>
      <div class="float-right bottom-btn">
        <el-button @click="onCancel">{{$t('graduationDesign.cancel')}}</el-button>
        <el-button type="danger" @click="onReject">{{$t('graduationDesign.reject')}}</el-button>
        <el-button type="primary" @click="onPass">{{$t('graduationDesign.pass')}}</el-button>
      </div>
    </el-card>

    <!--审核进度 在申报("ADD"),编辑("EDIT"),查看分配课题("VIEW_ASSIGN"),查看课题信息("VIEW_INFO")状态时不可见-->
    <DesignCard :title="$t('graduationDesign.reviewProgress')" v-if="REVIEW_PROGRESS.includes(actionType)">
      <edu-table ref="reviewProgressTable" :data="progressData" :selection="false" :pagination="false">
        <edu-table-column :label="$t('graduationDesign.time')" prop="time" :formatter="formatDate" min-width="120"></edu-table-column>
        <edu-table-column :label="$t('graduationDesign.approvers')" min-width="100">
          <template slot-scope="scope">
            <span>{{scope.row.approvorName}}【{{scope.row.approvorId}}】</span>
          </template>
        </edu-table-column>
        <edu-table-column :label="$t('graduationDesign.role')" prop="role" min-width="90"></edu-table-column>
        <edu-table-column :label="$t('graduationDesign.approvalResult')" prop="result" min-width="90">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.result === 'COMMIT'" type="success">{{$t('graduationDesign.submit')}}</el-tag>
            <el-tag v-if="scope.row.result === 'Process'" type="success">{{$t('graduationDesign.pass')}}</el-tag>
            <el-tag v-if="scope.row.result === 'End'" type="info">{{$t('graduationDesign.over')}}</el-tag>
            <el-tag v-if="scope.row.result === 'Reject'" type="warning">{{$t('graduationDesign.rejected')}}</el-tag>
          </template>
        </edu-table-column>
        <edu-table-column :label="$t('graduationDesign.approvalRemark')" prop="content" min-width="120"></edu-table-column>
      </edu-table>
    </DesignCard>
  </div>
</template>
<script>
import API from "common/src/api/underGraduationDesign/tutorDeclareSubject";
import filters from "common/src/filters";
import tools from 'common/src/views/underGraduationDesign/tools.js';
import retrainingArrangementVue from '../../../course/retrainingArrangement.vue';
export default {
  name: 'topicInfo',
  props: {
     dataInfo: {
      type: Object,
      default: {}
    },
    idTip:{
      type: String,
      default: ""
    },
    labelWidth: {
      type: String,
      default: "180px"
    },
    basicInfoForm: {
      type: Object,
      default: function () {
        return {
          projectName: '',
          subtitleName: '',
          researchDirection: '',
          introductionProject: '',
          college: '',
          subjectId: '',
          direction: '',
          isOutside: false,
          outsideTeacherNum: '',
          projectType: '',
          projectSourceId: '',
          projectNatureId: '',
          practiceSocialId: '',
          designPlace: '',
          teacherNum: ''
        };
      }
    },
    reviewForm: {
      type: Object,
      default: {
        remark: ''
      }
    },
    progressData: {
      type: Array,
      default: []
    },
    actionType: {
      type: String,
      default: ""
    },
    fromCheckDetail:{
      type: Boolean,
      required: false
    },
  },
  data() {
    return {
      api: API,
      source: {
        collegeOptions: [], // 学院
        subjectOptions: [], // 专业
        directionOptions: [], // 方向
        subjectSourceOptions: [], // 课题来源
        subjectNatureOptions: [], // 课题性质
        subjectTypeOptions: [{ // 课题类别
          label: "毕业论文",
          value: "毕业论文",
        }, {
          label: "毕业设计",
          value: "毕业设计",
        }],
        socialPracticeOptions: [], //其中社会时间情况
        outsideTutorOptions: [], // 校外导师
        innerTutorOptions: [], // 校内导师
        isTutorOptions: [{ // 是否有校外导师
          label: "是",
          value: true
        }, {
          label: "否",
          value: false
        }]
      },
      basicInfoRules: {
        projectName: [
          { required: true, message: this.$t('graduationDesign.pleaseEnter'), trigger: 'blur' }
        ],
        researchDirection: [
          { required: true, message: this.$t('graduationDesign.pleaseEnter'), trigger: 'blur' }
        ],
        introductionProject: [
          { required: true, message: this.$t('graduationDesign.pleaseEnter'), trigger: 'blur' }
        ],
        grade: [
          { required: true, message: this.$t('graduationDesign.pleaseChoose'), trigger: 'change' }
        ],
        isOutside: [
          { required: true, message: this.$t('graduationDesign.pleaseChoose'), trigger: 'change' }
        ],
        outsideTeacherNum: [
          { required: true, message: this.$t('graduationDesign.pleaseChoose'), trigger: 'change' }
        ],
        subjectId: [
          { required: true, message: this.$t('graduationDesign.pleaseChoose'), trigger: 'change' }
        ],
        projectType: [
          { required: true, message: this.$t('graduationDesign.pleaseChoose'), trigger: 'change' }
        ],
        projectSourceId: [
          { required: true, message: this.$t('graduationDesign.pleaseChoose'), trigger: 'change' }
        ],
        projectNatureId: [
          { required: true, message: this.$t('graduationDesign.pleaseChoose'), trigger: 'change' }
        ],
        practiceSocialId: [
          { required: true, message: this.$t('graduationDesign.pleaseChoose'), trigger: 'change' }
        ],
        designPlace: [
          { required: true, message: this.$t('graduationDesign.pleaseEnter'), trigger: 'blur' }
        ],
        teacherNum: [
          { required: true, message: this.$t('graduationDesign.pleaseChoose'), trigger: 'change' }
        ]
      },
      reviewRules: {
        remark: [
          { required: true, message: this.$t('graduationDesign.pleaseEnter'), trigger: 'blur' }
        ]
      },
      actionMap: {
        ADD: "新增课题",
        REVIEW_STU: "审核学生课题",
        REVIEW_TUTOR: "审核导师课题",
        EDIT: "编辑课题",
        VIEW_STU: "查看学生课题",
        VIEW_TUTOR: "查看导师课题",
        VIEW_TOPIC: "查看选题",
        VIEW_ASSIGN: "查看分配课题",
        VIEW_TUTOR_INFO: "查看课题信息-导师详情",
        VIEW_STU_INFO: "查看课题信息-学生详情",
        VIEW_STU_TOPIC_TUTOR: "查看学生选题-导师详情",
        VIEW_TOPIC_RESULT: "查看选题结果",
        VIEW_TOPIC_REASON: "审核学生选题-查看",
        REVIEW_TOPIC: "审核师生互选-审核",
        REVIEW_TOPIC_VIEW: "审核师生互选-查看",
      },
      // 导师基本信息可见
      TUTOR_BASIC_INFO: ['REVIEW_TUTOR', 'VIEW_TUTOR', 'ADD', 'EDIT', 'VIEW_STU_TOPIC_TUTOR', 'VIEW_TUTOR_INFO', 'VIEW_TOPIC_REASON', 'REVIEW_TOPIC', 'REVIEW_TOPIC_VIEW'],
      // 学生基本信息可见
      STUDENT_BASIC_INFO: ['REVIEW_STU', 'VIEW_STU', 'VIEW_STU_INFO', 'VIEW_TOPIC_REASON', 'REVIEW_TOPIC', 'REVIEW_TOPIC_VIEW'],
      // 选题可见
      TOPIC_VIEW: ['VIEW_ASSIGN', 'VIEW_TOPIC', 'VIEW_TOPIC_RESULT', 'REVIEW_TOPIC', 'REVIEW_TOPIC_VIEW'],
      // 审核可见
      REVIEW: ['REVIEW_TUTOR', 'REVIEW_STU', 'REVIEW_TOPIC'],
      // 审核进度可见
      REVIEW_PROGRESS: ['REVIEW_STU', 'REVIEW_TUTOR', 'VIEW_STU', 'VIEW_TUTOR', 'VIEW_TOPIC', 'VIEW_TOPIC_RESULT', 'VIEW_TOPIC_REASON', 'REVIEW_TOPIC', 'REVIEW_TOPIC_VIEW'],
      // 查看详情
      VIEW: ['VIEW_STU', 'VIEW_TUTOR', 'VIEW_TOPIC', 'VIEW_ASSIGN', 'VIEW_STU_TOPIC_TUTOR', 'VIEW_TUTOR_INFO', 'VIEW_STU_INFO', 'REVIEW_TUTOR', 'REVIEW_STU', 'VIEW_TOPIC_RESULT', 'VIEW_TOPIC_REASON', 'REVIEW_TOPIC', 'REVIEW_TOPIC_VIEW'],
      admissionGrade: '' //入学年级
    };
  },
  created() {
    if(this.dataInfo&&this.dataInfo.no){
    }else{
       this.getCollege();
      this.getOutsideTutorInfo();
      this.getInnerTutorInfo();
      this.getSubjectSource(this.basicInfoForm.grade);
      this.getSubjectNature(this.basicInfoForm.grade);
      this.getSocialPractice(this.basicInfoForm.grade);
      // 专业回显
      if (this.basicInfoForm.college && this.basicInfoForm.grade) {
        this.handleCollegeChange(this.basicInfoForm.college);
      }
      // 方向回显
      if (this.basicInfoForm.subjectId && this.basicInfoForm.direction) {
        this.handleSubjectChange(this.basicInfoForm.subjectId, "INIT");
      }
      // 查看课题时，去掉必填*标识
      if (this.VIEW.includes(this.actionType)) {
        this.basicInfoRules = {};
      }
    }

  },
  mounted() {
    this.reviewForm.remark = '';
  },
  methods: {
    formatDate(row, column, cellValue, index) {
      return filters.formatDate(cellValue, "yyyy/MM/dd hh:mm:ss");
    },
    // 选择年份 查专业 查课题来源等信息
    handleGradeChange(val) {
      this.basicInfoForm.subjectId = "";
      this.source.subjectOptions = [];
      if (val) {
        this.basicInfoForm.projectSourceId = "";
        this.basicInfoForm.projectNatureId = "";
        this.basicInfoForm.practiceSocialId = "";
        this.source.subjectSourceOptions = [];
        this.source.subjectNatureOptions = [];
        this.source.socialPracticeOptions = [];
        this.getSubjectSource(this.basicInfoForm.grade);
        this.getSubjectNature(this.basicInfoForm.grade);
        this.getSocialPractice(this.basicInfoForm.grade);
        if (this.basicInfoForm.college) {
          this.handleCollegeChange(this.basicInfoForm.college);
        }
      }
      this.$nextTick(() => {
        this.$refs.basicInfoForm.clearValidate();
      });
    },
    // 查学院
    getCollege() {
      this.source.collegeOptions = [];
      tools.initAllCollege(this.source.collegeOptions);
      /*this.api.getCollege().then(res => {
        this.source.collegeOptions = res;
      });*/
    },
    // 选择年份和学院查专业
    handleCollegeChange(val) {
      if (val && this.basicInfoForm.grade) {
        const params = {
          grade: this.basicInfoForm.grade,
          college: val
        };
        this.api.getSubject(params).then(res => {
          this.source.subjectOptions = res.data;
        }).catch();
      }
    },
    // 选择年份和专业查方向
    handleSubjectChange(val, type = "") {
      if (type !== "INIT") {
        this.basicInfoForm.direction = "";
      }
      this.source.directionOptions = [];
      if (val) {
        if (type === "INIT") {
          this.admissionGrade = this.basicInfoForm.admissionGrade;
        } else {
          this.admissionGrade = this.findAdmissionGrade();
        }
        const params = {
          keyWord: "",
          pageNum_: 1,
          pageSize_: 50,
          grade: this.admissionGrade,
          professionCode: val
        };
        this.api.getDirection(params).then(res => {
          this.source.directionOptions = this.optionFormat(res.data.list, "name", "code");
        }).catch();
      }
    },
    // 查校外导师
    getOutsideTutorInfo() {
      this.api.getOutsideTutor().then(res => {
        this.source.outsideTutorOptions = this.optionFormat(res.data, "name", "id");
      }).catch();
    },
    // 查校内导师
    getInnerTutorInfo() {
      this.api.getInnerTutor().then(res => {
        this.source.innerTutorOptions = this.optionFormat(res.data, "name", "code");
      }).catch();
    },
    // 查课题来源
    getSubjectSource(val) {
      const params = {
        year: val
      };
      this.api.getSource(params).then(res => {
        this.source.subjectSourceOptions = this.optionFormat(res.data, "subjectSource", "id");
      }).catch();
    },
    // 查课题性质
    getSubjectNature(val) {
      const params = {
        year: val
      };
      this.api.getNature(params).then(res => {
        this.source.subjectNatureOptions = this.optionFormat(res.data, "subjectProperties", "id");
      }).catch();
    },
    // 查社会实践
    getSocialPractice(val) {
      const params = {
        year: val
      };
      this.api.getPractice(params).then(res => {
        this.source.socialPracticeOptions = this.optionFormat(res.data, "sociaPractice", "id");
      }).catch();
    },
    // 下拉数据 格式化
    optionFormat(optionList = [], label = "", value = "") {
      let dataset = [];
      for (let i = 0; i < optionList.length; i++) {
        const optionObj = {
          label: optionList[i][label],
          value: optionList[i][value]
        };
        dataset.push(optionObj);
      }
      return dataset;
    },
    // 匹配入学年级
    findAdmissionGrade() {
      const subjectIdItem = this.source.subjectOptions.find(item => item.subjectId === this.basicInfoForm.subjectId);
      return subjectIdItem ? subjectIdItem.admissionGrade : "";
    },
    // 保存
    onSave() {
      this.basicInfoForm.admissionGrade = this.admissionGrade;
      const params = {
        actionType: this.actionType,
        data: this.basicInfoForm
      };
      this.$emit("topic-save", params);
    },
    // 提交
    onSubmit() {
      this.basicInfoForm.admissionGrade = this.admissionGrade;
      this.$emit("topic-submit", this.basicInfoForm);
    },
    // 通过
    onPass() {
      let params = {};
      params = {
        applicationStudentEntities: [{ ...this.basicInfoForm }],
        optInfoEntities: [{ ...this.basicInfoForm }],
        basicInfoForm: { ...this.basicInfoForm },
        firstStatus: "End",
        content: ""
      };

      this.reviewRules.remark = [];
      this.$refs.reviewForm.clearValidate();
      this.$emit("topic-pass", params);
    },
    // 驳回
    onReject() {
      let params = {};
      params = {
        applicationStudentEntities: [{ ...this.basicInfoForm }],
        optInfoEntities: [{ ...this.basicInfoForm }],
        basicInfoForm: { ...this.basicInfoForm },
        firstStatus: "Reject",
        content: this.reviewForm.remark
      };
      this.reviewRules.remark = [{ required: true, message: this.$t('graduationDesign.pleaseEnter'), trigger: 'blur' }];
      this.$refs.reviewForm.validate(valid => {
        if (valid) {
          this.$emit("topic-reject", params);
        } else {
          return false;
        }
      });
    },
    // 取消
    onCancel() {
      if(this.dataInfo&&this.dataInfo.no){
        this.$router.go(-1);
      }else{
        this.$emit("topic-cancel");
      }

    }
  }
}
</script>
<style lang="scss" scoped>
.topic-info {
    .topic-title {
        color: #2b3b4e;
        font-size: 18px;
        line-height: 24px;
        font-weight: bold;
    }
    .topic-input-select {
        width: 100%;
    }
    .topic-form-title {
        ::v-deep .el-form-item__label {
            font-weight: bold;
        }
    }
    .bottom-btn {
        margin-bottom: 10px;
    }
}
</style>
